//
//  ProjectCell.m
//  MyTrip
//
//  Created by zhang on 15/8/24.
//  Copyright (c) 2015年 张益. All rights reserved.
//

#import "ProjectCell.h"
#import "Project.h"
#import "UIImageView+WebCache.h"
#define ScreenWidth [[UIScreen mainScreen] bounds].size.width

@implementation ProjectCell

- (void)dealloc
{
    [_subLabel release];
    [_titleLabel release];
    [_picImage release];
    [super dealloc];
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.picImage = [[[UIImageView alloc] initWithFrame:CGRectMake(5 * OffWidth, 5 * OffHeight, ScreenWidth - 10 * OffWidth, (200 - 10) * OffHeight)] autorelease];
        [self.contentView addSubview:_picImage];
        _picImage.layer.cornerRadius = 5;
        _picImage.layer.masksToBounds = YES;
        
        self.titleLabel = [[[UILabel alloc] initWithFrame:CGRectMake(5 * OffWidth, 5 * OffHeight, 300 * OffWidth, 40 * OffHeight)] autorelease];
        _titleLabel.center = CGPointMake(ScreenWidth / 2, (200 / 2 - 20) * OffHeight);
        [self.contentView addSubview:_titleLabel];
        _titleLabel.textColor = [UIColor whiteColor];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        
        self.subLabel = [[[UILabel alloc] initWithFrame:CGRectMake(5 * OffWidth, 5 * OffHeight, 200 * OffWidth, 40 * OffHeight)] autorelease];
        _subLabel.center = CGPointMake(ScreenWidth / 2, (200 / 2 + 20) * OffHeight);
        [self.contentView addSubview:_subLabel];
        _subLabel.textColor = [UIColor whiteColor];
        _subLabel.textAlignment = NSTextAlignmentCenter;
        
    }
    return self;
}


- (void)setvalueWithProject:(Project *)project{
    [_picImage sd_setImageWithURL:[NSURL URLWithString:project.pic] placeholderImage:[UIImage imageNamed:@"zhanweitu.jpg"]];
    [_titleLabel setText:project.title];
    _titleLabel.font = [UIFont systemFontOfSize:23];
    
    [_subLabel setText:project.subtitle];
    _subLabel.font = [UIFont systemFontOfSize:15];
    
}




- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
